"use strict";
import * as React from 'react';
import { commonStyles } from "../assets/styles/common";
import Avatar from "./Avatar";
import MyText from "./MyText";
import Colors from "../assets/styles/Colors";
import Request from "../utils/Request";
const moment = require("moment");
const { View, TouchableOpacity } = require('react-native');
const { connect } = require('react-redux');
class NoticeItem extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.getText = () => `${this.props.item.nickname ? '您的联系人' : ''}${this.props.item.nickname}给您发了一条新消息`;
        this.getTime = () => {
            return moment(this.props.item.sendTime).format('MM-DD HH:mm');
        };
    }
    render() {
        return (<TouchableOpacity style={[commonStyles.flexRow, commonStyles.relative, {
                padding: 10,
                alignItems: 'center',
            }]} onPress={this.props.onPress}>
                <Avatar source={{ uri: Request.checkImageUrl(this.props.item.avatar) + '' }}/>
                <MyText numberOfLines={2} style={{ marginLeft: 5 }}>{this.getText()}</MyText>
                <View style={[commonStyles.absolute, { top: 5, right: 5 }]}>
                    <MyText fontSize={12} color={Colors.Black}>{this.getTime()}</MyText>
                </View>
            </TouchableOpacity>);
    }
}
NoticeItem.defaultProps = {
    onPress: null
};
export default NoticeItem;
